package immutable;

/**
 * 参考：https://zhuanlan.zhihu.com/p/38004627
 * 当你获得这个类的一个实例引用时，你不可以改变这个实例的内容
 */
public final class ImmutableCircle {

    private final Point center; // 圆心

    private final int radius; // 半径

    public ImmutableCircle(int x, int y, int radius) {
        center = new Point(x, y);
        this.radius = radius;
    }

    public Point getCenter() {
        return new Point(center.getX(), center.getY());
    }

    public int getRadius() {
        return radius;
    }

    @Override
    public String toString() {
        return "ImmutableCircle{" +
                "center=" + center +
                ", radius=" + radius +
                '}';
    }

    public static void main(String[] args) {
        System.out.println(new ImmutableCircle(10, 10, 20));
    }
}
